<template>
  <demoBlock title="异步控制" padding>
    <vcu-switch :model-value="checked" @update:model-value="onUpdateValue" />
  </demoBlock>
</template>

<script>
import { Dialog } from "../../../components";
import { defineComponent, ref } from "vue";

export default defineComponent({
  setup() {
    const checked = ref(true);
    const onUpdateValue = (val) => {
      Dialog.confirm({
        title: "提示",
        message: "是否切换开关？",
      }).then((action) => {
        console.info()
        checked.value = action == "confirm" ? val : !val;
      });
    };
    return { checked, onUpdateValue };
  },
});
</script>
